package movie.test.as.category.biz;

import java.util.List;
import java.util.Map;

import movie.test.as.category.dao.CategoryDao;
import movie.test.common.BaseBiz;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

@Component
public class CategoryBiz extends BaseBiz {

	@Autowired
	private CategoryDao categoryDao;

	public int addCategory(JSONObject objs) {

		return categoryDao.addCategory(objs);
	}

	public int updateCategory(JSONObject objs) {

		return categoryDao.updateCategory(objs);
	}

	public int deleteCategory(JSONObject objs) {

		return categoryDao.deleteCategory(objs);
	}

	public List<Map<String, Object>> findAllCategory(JSONObject objs) {
		/* PageHelper.startPage(getPagePara(objs)); */
		Integer pageNum = (Integer) objs.get("pageNum");
		Integer pageSize = (Integer) objs.get("pageSize");
		PageHelper.startPage(pageNum, pageSize);
		System.out.println(objs);
		List<Map<String, Object>> list = categoryDao.findAllCategory(objs);
		return list;
	}

	public PageInfo<Map<String, Object>> getMovieInfoByCategoryId(JSONObject objs) {
		return categoryDao.getMovieInfoByCategoryId(objs);
	}

	public Map<String, Object> getCategoryById(JSONObject objs) {

		return categoryDao.getCategoryById(objs);
	}

	public List<Map<String, Object>> findCategory(JSONObject objs) {

		return categoryDao.findCategory(objs);
	}

}
